package com.atguigu.composite;

import java.util.ArrayList;
import java.util.List;

//University 就是 Composite ,可以管理 college
public class University extends OrganizationComponent {
	
	List<OrganizationComponent> organizationComponents = new ArrayList<OrganizationComponent>();

	//构造器
	public University(String name, String des) {
		super(name, des);
	}
	
	//重写add
	@Override
	protected void add(OrganizationComponent organizationComponent) {
		organizationComponents.add(organizationComponent);
	}
	
	//重写remove
	@Override
	protected void remove(OrganizationComponent organizationComponent) {
		organizationComponents.remove(organizationComponent);
	}

	//print方法，就是输出University 包含的学院
	@Override
	protected void print() {
		System.out.println("--------"+getName()+"-----------------");
		//遍历organizationComponents
		for (OrganizationComponent organizationComponent : organizationComponents) {
			organizationComponent.print();
		}
	}

}
